<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script type="text/javascript">
        /* 
            Array.from
                将伪数组转成真正数组
                对象转数组
        */
        let arrOjb = {
            "0": 2,
            "1": 3,
            "length": 2
        }
        let newArr = Array.from(arrOjb, item => item * 2);
        console.log(newArr);

        /* 
            Array.find
                 找出第一个符合条件的数组成员,  如果没有返回undefined
        */

        var o = [{
            name: 'jack',
            id: 1
        }, {
            name: 'jack',
            id: 2
        }]

        // var res = o.find((item, index) => {
        //     return item.id == 2
        // })
        //简化
        var res = o.find(item => item.id == 2)
        console.log(res);

        /* 
            Array.findIndex
                 找出第一个符合条件的数组成员下标,  如果没有返回 -1
        */
        let ok = [1, 2, 6, 8, 10]
        let i = ok.findIndex(item => item > 8);
        console.log(i);

        /* 
            Array.includes
                 数组是否包含给定的值，返回值为boolean
        */
        let op = ['a', 'c', 'e', 'f']
        console.log(op.includes('a'));
        console.log(op.includes('g'));
    </script>
</body>

</html>